﻿namespace SilverCrmSoap.CrmSdk
{
    public partial class Entity
    {
        internal void SetAttributeValue<T>(string key, T value)
        {
            var lkey = key.ToLower();
            if (Attributes.ContainsKey(lkey))
            {
                if (value.Equals(GetAttributeValue<T>(lkey))) return;
                Attributes.SetItem(lkey, value);
            }
            else
            {
                Attributes.Add(new KeyValuePair<string, object> { Key = lkey, Value = value });
            }
            
            if (PropertyChanged!=null) RaisePropertyChanged(key);
        }
    }
}
